package calorie.com.calorie.contact;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.Md5Utils;


import calorie.com.calorie.api.ApiService;
import calorie.com.calorie.request.AddUserRequest;
import calorie.com.calorie.response.ResultDTO;
import retrofit2.Call;
import retrofit2.Response;

public class AddUserContact {
    public static class AddUserPresent extends BasePresent<IAddUserView> {
        public void addUser(Integer userId, String account, String loginPassword,String dealPwd) {
            ApiService service = ServiceGenerator.createService(ApiService.class);
            AddUserRequest request = new AddUserRequest(userId,account,Md5Utils.stringToMD5(loginPassword), Md5Utils.stringToMD5(dealPwd));
            service.addUser(request).enqueue(new NetCallBack<ResultDTO>() {
                @Override
                public void onSuccess(Call<ResultDTO> call, Response<ResultDTO> response) {
                    if(getView()!=null){
                        getView().getResultDate(response);
                    }
                }

                @Override
                public void onFailed() {

                }
            });
        }
    }

    public interface IAddUserView extends IBaseView {
        void getResultDate(Response<ResultDTO> resultDTOResponse);
    }
}
